package com.itheima.common;

import com.itheima.pojo.Employee;

/**
 * @Description: ThreadLocal在同一个线程中共享数据，用来给公共填充类提供修改管理员的id
 * @Create by: JJ菜菜
 * @Date: 2021/11/1 18:24
 */
public class GetThreadLocal {

    private static final ThreadLocal<Long> threadLocal = new ThreadLocal<>();

    /**
     * 向ThreadLocal中储存登录管理员的id
     * @param id
     */
    public static void setThreadLocal(Long id){
        threadLocal.set(id);
    }

    /**
     * 从ThreadLocal中获取存的数据
     * @return
     */
    public static Long getThreadLocal(){
        Long id = threadLocal.get();
        return id;
    }
}
